home *** CD-ROM | disk | FTP | other *** search
/ MACD 5 / MACD 5.bin / workbench / libs / intuisup.lha / Intuisup / source.lha / Files / files2.asm < prev    next >
Assembly Source File  |  1992-10-21  |  4KB  |  168 lines

  1.  * $Revision Header *** Header built automatically - do not edit! ***********
  2.  *
  3.  *    (C) Copyright 1992 by Torsten Jürgeleit
  4.  *
  5.  *    Name .....: files2.asm
  6.  *    Created ..: Wednesday 22-Oct-92 15:23:51
  7.  *    Revision .: 0
  8.  *
  9.  *    Date        Author                 Comment
  10.  *    =========   ====================   ====================
  11.  *    22-Oct-92   Torsten Jürgeleit      Created this file!
  12.  *
  13.  ****************************************************************************
  14.  *
  15.  *    DOS calls between open and close of dos library -> neccessary for
  16.  *    DOS calls from within intuisup.library
  17.  *
  18.  * $Revision Header ********************************************************/
  19.  
  20. ;---------------------------------------------------------------------------
  21. ; Support macros
  22. ;---------------------------------------------------------------------------
  23.  
  24. PUSH    MACRO
  25.     movem.l    \1,-(sp)
  26.     ENDM
  27.  
  28. PULL    MACRO
  29.     movem.l    (sp)+,\1
  30.     ENDM
  31.  
  32. CALLSYS    MACRO
  33.     XREF    _LVO\1
  34.     jsr    _LVO\1(a6)
  35.     ENDM
  36.  
  37. ;---------------------------------------------------------------------------
  38. ; External definitions
  39. ;---------------------------------------------------------------------------
  40.  
  41.     XDEF    _dos_open
  42.     XDEF    _dos_read
  43.     XDEF    _dos_close
  44.  
  45. ;---------------------------------------------------------------------------
  46. ; BPTR dos_open(BYTE *name, LONG flags)
  47. ;                    a0         d0
  48. ;---------------------------------------------------------------------------
  49.  
  50. _dos_open:
  51.     PUSH    d2-d3/a2/a6
  52.  
  53.     ; --- save parameters
  54.     move.l    a0,a2            ; a2 := file name ptr
  55.     move.l    d0,d2            ; d2 := flags
  56.     moveq    #0,d3            ; d3 := return code
  57.  
  58.     ; --- open dos library
  59.     move.l    (4).w,a6        ; a6 := SysBase
  60.     lea    dos_name(pc),a1        ; a1 := library name
  61.     moveq    #0,d0            ; d0 := version
  62.     CALLSYS    OpenLibrary
  63.     tst.l    d0
  64.     beq.s    do_exit
  65.  
  66.     ; --- call DOS function Open()
  67.     move.l    d0,a6            ; a6 := DosBase
  68.     move.l    a2,d1            ; d1 := file name ptr
  69.                     ; d2 := flags
  70.     jsr    -$1e(a6)        ; CALLSYS Open -> Bug in c16.lib (POSITIVE lib offset)
  71.     move.l    d0,d3            ; d3 := BPTR to file handle
  72.  
  73.     ; --- close dos library
  74.     move.l    a6,a1            ; a1 := DosBase
  75.     move.l    (4).w,a6        ; a6 := SysBase
  76.     CALLSYS    CloseLibrary
  77.  
  78. do_exit:
  79.     ; --- prepare return code
  80.     move.l    d3,d0
  81.  
  82.     PULL    d2-d3/a2/a6
  83.     rts
  84.  
  85. ;---------------------------------------------------------------------------
  86. ; LONG dos_read(BPTR fh, BYTE *buffer, LONG size);
  87. ;                  a0         a1          d0
  88. ;---------------------------------------------------------------------------
  89.  
  90. _dos_read:
  91.     PUSH    d2-d4/a2-a3/a6
  92.  
  93.     ; --- save parameters
  94.     move.l    a0,a2            ; a2 := BPTR to file handle
  95.     move.l    a1,a3            ; a3 := buffer ptr
  96.     move.l    d0,d3            ; d3 := size
  97.     moveq    #-1,d4            ; d4 := return code
  98.  
  99.     ; --- open dos library
  100.     move.l    (4).w,a6        ; a6 := SysBase
  101.     lea    dos_name(pc),a1        ; a1 := library name
  102.     moveq    #0,d0            ; d0 := version
  103.     CALLSYS    OpenLibrary
  104.     tst.l    d0
  105.     beq.s    dr_exit
  106.  
  107.     ; --- call DOS function Read()
  108.     move.l    d0,a6            ; a6 := DosBase
  109.     move.l    a2,d1            ; d1 := BPTR to file handle
  110.     move.l    a3,d2            ; d2 := buffer ptr
  111.                     ; d3 := size
  112.     jsr    -$2a(a6)        ; CALLSYS Read -> Bug in c16.lib (POSITIVE lib offset)
  113.     move.l    d0,d4            ; d4 := num of characters read
  114.  
  115.     ; --- close dos library
  116.     move.l    a6,a1            ; a1 := DosBase
  117.     move.l    (4).w,a6        ; a6 := SysBase
  118.     CALLSYS    CloseLibrary
  119.  
  120. dr_exit:
  121.     ; --- prepare return code
  122.     move.l    d4,d0
  123.  
  124.     PULL    d2-d4/a2-a3/a6
  125.     rts
  126.  
  127. ;---------------------------------------------------------------------------
  128. ; VOID dos_close(BPTR fh);
  129. ;                   a0
  130. ;---------------------------------------------------------------------------
  131.  
  132. _dos_close:
  133.     PUSH    a2/a6
  134.  
  135.     ; --- save parameters
  136.     move.l    a0,a2            ; a2 := BPTR to file handle
  137.  
  138.     ; --- open dos library
  139.     move.l    (4).w,a6        ; a6 := SysBase
  140.     lea    dos_name(pc),a1        ; a1 := library name
  141.     moveq    #0,d0            ; d0 := version
  142.     CALLSYS    OpenLibrary
  143.     tst.l    d0
  144.     beq.s    dc_exit
  145.  
  146.     ; --- call DOS function Close()
  147.     move.l    d0,a6            ; a6 := DosBase
  148.     move.l    a2,d1            ; d1 := BPTR to file handle
  149.     jsr    -$24(a6)        ; CALLSYS Close -> Bug in c16.lib (POSITIVE lib offset)
  150.  
  151.     ; --- close dos library
  152.     move.l    a6,a1            ; a1 := DosBase
  153.     move.l    (4).w,a6        ; a6 := SysBase
  154.     CALLSYS    CloseLibrary
  155.  
  156. dc_exit:
  157.     PULL    a2/a6
  158.     rts
  159.  
  160. ;---------------------------------------------------------------------------
  161. ; Static data
  162. ;---------------------------------------------------------------------------
  163.  
  164. dos_name:
  165.     dc.b    "dos.library"
  166.  
  167.     END
  168.